<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p class="ppp">1</p>
    <p class="ppp">2</p>
    <p class="ppp">3</p>
    <p class="ppp">4</p>
    <script>
        var Ps = document.getElementsByTagName("p");
        // var Ps = document.getElementsByClassName("ppp");
        console.log(Ps);

        var NewPs = [...Ps];
        // console.log(NewPs);

        NewPs.forEach(function (item) {
            item.onclick = function () {
                console.log(item);
            }
        })
    </script>
</body>

</html>